<?php

include 'quiz_soal_controller.php';

if ($_GET['action'] == "view") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo viewBankSoal($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "viewSQ") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo viewSoalQuiz($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "viewMhs") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo viewSoalQuizMhs($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "add") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo createSoal($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "addSQ") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        echo createSoalQuiz($json);
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "update") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (updateSoal($json))
            echo 'Update Success.';
        else
            echo 'Update Failed!';
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "delete") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (deleteSoal($json))
            echo 'Delete Success.';
        else
            echo 'Delete Failed!';
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "save") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (saveSoalQuiz($json))
            echo 'Saving Success.';
        else
            echo 'Saving Failed!';
    } else {
        echo 'Invalid Request';
    }
} else if ($_GET['action'] == "remove") {
    $json = $HTTP_RAW_POST_DATA;
    if ($json != NULL) {
        if (removeSoalQuiz($json))
            echo 'Saving Success.';
        else
            echo 'Saving Failed!';
    } else {
        echo 'Invalid Request';
    }
} else {
    echo 'Action not defined!';
}
?>
